#include "partition_driver.h"

#define STORAGE "storage"

esp_err_t read_partition(size_t src_offset,void *dst, size_t size)
{
    esp_err_t err;
    const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, STORAGE);
    err = esp_partition_read(partition,src_offset,dst,size);
    return err;
}

esp_err_t write_partition(size_t src_offset,const void *src, size_t size)
{
    esp_err_t err;
    const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, STORAGE);
    ESP_ERROR_CHECK(esp_partition_erase_range(partition,src_offset,0x1000));
    err = esp_partition_write(partition,src_offset,src,size);
    return err;
}



